import { request } from "../../utils/https";
// pages/dai/dai.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
  number:"",
  code:"",
  password:""
  },
  bindblurUserName(e){
    let _self = this;
  // console.log(e);
  let value =e.detail.value;
  _self.data.number = value;
  _self.setData({
    number:_self.data.number
  })
  },
  bindcode(e){
    let _self = this;
    console.log(e);
    console.log(_self.data.number);
    let value =e.detail.value;
    _self.data.code = value;
    _self.setData({
      code:_self.data.code
    })
  },
  bindpassword(e){
    let _self = this;
    console.log(e);
    let value =e.detail.value;
    _self.data.password = value;
    _self.setData({
      password:_self.data.password
    })
  },
  getcode(){
    let _self =this;
    // console.log(_self.data.number);
  request(
    "register/verify",
  {
    "phone":_self.data.number,
    "type":"register"
  },
  "POST",
  function(res){
   console.log(res);
    wx.showToast({
      title:res.data.msg,
      icon:"none"
    })
  }
  )
  },
  register(){
    let _self=this;
request(
  "register",
  {
    "account":_self.data.number, 
    "captcha":_self.data.code, 
    "password":_self.data.password, 
    "inviteCode":"", 
    "spread":""
  },
"POST",
function(res){
  console.log(res);
  wx.showToast({
    title:"已注册成功",
    icon:"none"
  })
  wx.redirectTo({
    url: '/pages/logoin/logoin',
  })
}
)
  },
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad(options) {

  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady() {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow() {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide() {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload() {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh() {

  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom() {

  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage() {

  }
})